﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLDC.Common.Estate;
using ZLDC.Topo.BLL.Estate;
using System.Data;
using System.Text;
using ZLDC.Common.BaseUser;

namespace ZLDC.Estate.TM
{
    public partial class RoomList : _PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RoomNoBLL rbll = new RoomNoBLL();
                //加载人员名称，部门，部门ID
                iUserName.Value = this.info.m_sUserName;
                iUserDept.Value = this.info.m_sDeptName;
                ideptid.Value = this.info.m_sDeptID;
                //根据栋阁编号去栋阁名称
                int bid = _Request.GetInt("id", 0);
                DataSet ds = rbll.SelectNameByBid(bid);
                string bname = "";
                if (ds != null)
                {
                    bname = ds.Tables[0].Rows[0]["finalName"].ToString();
                }
                StringBuilder sb = new StringBuilder();
                sb.Append("<table id='tableList1' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
                sb.Append("  <tr>");
                sb.Append("   <td height='25' bgcolor='F7F7F7'>");
                
                if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("删除房号"))
                {
                    sb.Append("      <input type='checkbox' name='checkboxAll' id='checkboxAll' onclick='cbSelectAll()' />全选");
                    sb.Append("      <input id='btnDelRoomno' type='button' value='批量删除' class='button_bak' onclick='delAll()'/> ");
                }
                // 权限判断
                if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("直接添加房号"))
                    sb.Append("&nbsp;&nbsp;&nbsp;<input id='btnAddRoomno' type='button' value='添加房号' class='button_bak' onClick=\"ShowDialog('RoomNo.aspx','Add','" + bid + "','')\"/>&nbsp;&nbsp;&nbsp;&nbsp;");
                Random rd = new Random();
                
                if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("申请添加房号")) 
                {
                    sb.Append("<input id='btnSaddRoomNo' type='button' class='button_bak' onClick=\"ShowDialog('RoomNo.aspx','SqAdd&rd=" + rd.Next(2) + "','" + bid + "','')\" value='申请房号'/></br>");
                }
                sb.Append("   </td>");
                sb.Append("</tr>");
                sb.Append("  <tr>");
                sb.Append("   <td height='25' bgcolor='F7F7F7'>");
                sb.Append("栋阁名称：<input id='txtEsate' name='txtEsate' type='text'  value='" + bname + "' readonly  class='textstyle1' style='width: 30%' />&nbsp;&nbsp;&nbsp;</br>");
                sb.Append("   </td>");
                sb.Append("</tr>");
                sb.Append("  <tr>");
                sb.Append("   <td height='25' bgcolor='F7F7F7'>");
                sb.Append("     <table><tr><td style=\"background-color:#FF99FF; width:50px; height:\"></td>");
                sb.Append("     <td>正在出售&nbsp;&nbsp;</td>");
                sb.Append("     <td style=\"background-color:Yellow; width:50px; height:\"></td>");
                sb.Append("     <td>正在出租&nbsp;&nbsp;</td>");
                sb.Append("     <td style=\"background-color:#66CCFF; width:50px; height:\"></td>");
                sb.Append("     <td>即租又售&nbsp;&nbsp;&nbsp;&nbsp;</td>");
                sb.Append("     <td>无背景色表示未放盘源</td>");
                sb.Append("     </tr></table>");
                sb.Append("   </td>");
                sb.Append("</tr>");
                sb.Append("</table>");
                ltDiv.Text = sb.ToString();

                btnCompetences();   // 权限控制按钮
            }

        }

        // 权限控制按钮
        private void btnCompetences()
        {                            
            if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("修改房号"))
                hCompetencesIsEdit.Value = "1";
            if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("删除房号"))
                hCompetencesIsDel.Value = "1";
            if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("申请添加别名"))
                hCompetencesIsOtherName.Value = "1";
        }

    }


}
